package com.k.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.k.demo.entity.ShoppingCartDetail;

@Mapper
public interface ShoppingCartDetailMapper {
	
	@Select("select * from shopping_cart_detail where shopping_cart_id=#{shopping_cart_id} and food_id=#{food_id} and detail_attach=#{detail_attach} and is_delete=1")
	ShoppingCartDetail selectByIdAndAttach(int shopping_cart_id,int food_id,String detail_attach);
	
	int insertShoppingCartDetail(ShoppingCartDetail shoppingCartDetail);
	
	int updateShoppingCartDetail(ShoppingCartDetail shoppingCartDetail);
	
	//根据购物车ID和菜品ID查询购物车明细
	ShoppingCartDetail selectCartDetailById(@Param("cartID") int cartID,@Param("foodID") int foodID);
	
	//根据购物车ID查询该购物车下的所有购物车明细
	List<ShoppingCartDetail> selectCartDetails(int cartID);
	
	//假删除购物明细
	@Update("update shopping_cart_detail set is_delete=0 where shopping_cart_detail_id=#{value}")
	int deleteShoppingDetail(int detailID);
	

	//查询带有Food的明细
	ShoppingCartDetail selectDetail(@Param("cartlID") int detailID,@Param("foodID") int foodID,@Param("detail_attach") String detail_attach);
	
	@Update("update shopping_cart_detail set is_delete=0 where shopping_cart_id=#{shopping_cart_id} and food_id=#{food_id} and detail_attach=#{detail_attach}")
	int deleteDetail(ShoppingCartDetail shoppingCartDetail);

	//假购物车明细批量删除
	boolean deleteShoppingDetailIn(List<Integer> list);

}
